package com.t382.text.service.imp;

import com.t382.text.mapper.IntMapper;
import com.t382.text.pojo.HotSpotConsultation;
import com.t382.text.pojo.Interceptors;
import com.t382.text.pojo.Page;
import com.t382.text.pojo.Replies;
import com.t382.text.service.InterceptorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InterceptorsServiceImp implements InterceptorsService {
    @Autowired
    private IntMapper intMapper;

    @Override
    public Page getPage(Integer pageNo, Integer pageSize) {
        Page page = new Page();
        try {
            page.setPageNo(pageNo);
            page.setPageSize(pageSize);
            Long total = intMapper.count();
            page.setTotalCount(total.intValue());
            int offset = (pageNo - 1) * pageSize;
            List<Interceptors> list = intMapper.getPage(offset, pageSize);//调用mapper的分页方法
            System.out.println(list);
            page.setList(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return page;
    }

    @Override
    public List<HotSpotConsultation> getReplies(int id) {
        return intMapper.getReplies(id);
    }

    @Override
    public int delete(Integer id) {
        return intMapper.delete(id);
    }

    @Override
    public int update1(Integer id) {
        return intMapper.update1(id);
    }

    @Override
    public int update2(Replies replies) {
        return intMapper.update2(replies);
    }

    @Override
    public int update3(Integer id) {
        return intMapper.update3(id);
    }
}
